package it.unisalento.appsalento.adapter;

import it.unisalento.R;
import it.unisalento.appsalento.model.Appello;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class AppelliCalendarioAdapter extends ArrayAdapter<Appello> {
	
	public AppelliCalendarioAdapter(Context context, int textViewResourceId,
			ArrayList<Appello> objects) {
        super(context, textViewResourceId, objects);
    }

	@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.row_appello_calendario, null);
        TextView nomeEsame = (TextView)convertView.findViewById(R.id.nomeEsame);
        TextView annoCorso = (TextView)convertView.findViewById(R.id.annoCorso);
        TextView idAppello = (TextView)convertView.findViewById(R.id.idAppello);
        TextView dataProvaScritta = (TextView)convertView.findViewById(R.id.dataProvaScritta);
        TextView dataProvaOrale = (TextView)convertView.findViewById(R.id.dataProvaOrale);
        Appello appello = getItem(position);
        
        nomeEsame.setText(appello.getNomeEsame());
        annoCorso.setText(appello.getAnnoCorso());
        idAppello.setText(appello.getIdAppello());

        dataProvaOrale.setText(android.text.format.DateFormat.format("dd/MM/yyyy", appello.getDataProvaOrale()));
        dataProvaScritta.setText(android.text.format.DateFormat.format("dd/MM/yyyy", appello.getDataProvaScritta()));
        return convertView;
    }
	
	

}
